$(document).ready(function(){
	active();
	initBlogArticle();
	getPosition();
})
function getBlogByArticle(size,index){
	var url = "/HyperIT/userdetail/findUdByArticle";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getBlogByExp(size,index){
	var url = "/HyperIT/userdetail/findUdByEXP";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getBlogByNote(size,index){
	var url = "/HyperIT/userdetail/findUdByNote";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getBlogByAccept(size,index){
	var url = "/HyperIT/userdetail/findUdByAccept";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getBlogByKey(size,index){
	if($("#articleSearch").val().trim()==""){
		messageTip("请输入标签的关键字");
	}else{
		$(".items .blog_item").remove();
		var url = "/HyperIT/userdetail/searchBlog";
		var parm = "size="+size+"&indexPageNum="+index+"&search="+$("#articleSearch").val();
		$.get(url,parm,function(data){
			if (data.serviceResult) {
				var list = data.resultParm.userDetail_list;
				showBloger(list);
			} else{
				messageTip(data.resultInfo);
			}
		});
	}
}
function getBlogByPosition(which,size,index,positionId){
	$(which).parent().addClass("active").siblings().removeClass("active");
	$("#ranking li").removeClass("active");
	$(".items .blog_item").remove();
	var url = "/HyperIT/userdetail/searchBlogByPosition";
	var parm = "size="+size+"&indexPageNum="+index+"&position_id="+positionId;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function getBlogByTime(size,index){
	var url = "/HyperIT/userdetail/getAllUserInfo";
	var parm = "size="+size+"&indexPageNum="+index;
	$.get(url,parm,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.userDetail_list;
			showBloger(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function active(){
	$("#ranking ul").children("li").click(function(){
		$(this).addClass("active").siblings().removeClass("active");
		$("#position li").removeClass("active");
		selectCard($(this).index());
	});
}
function selectCard(index){
	switch (index){
		case 0:
			initBlogArticle();
			break;
		case 1:
			initBlogAccept();
			break;
		case 2:
			initBlogNote();
			break;
		case 3:
			initBlogLevel();
			break;
		case 4:
			initBlogFans();
			break;
		case 5:
			initBlogTime();
			break;
		default:
			break;
	}
}
function initBlogArticle(){
	$(".items").children(".blog_item").remove();
	getBlogByArticle(100000,1);
}
function initBlogAccept(){
	$(".items").children(".blog_item").remove();
	getBlogByAccept(100000,1);
}
function initBlogQuestion(){
	$(".items").children(".blog_item").remove();
	getBlogByNote(100000,1);
}
function initBlogLevel(){
	$(".items").children(".blog_item").remove();
	getBlogByExp(100000,1);
}
function initBlogTime(){
	$(".items").children(".blog_item").remove();
	getBlogByTime(100000,1);
}
function initBlogFans(){
	$(".items").children(".blog_item").remove();
	getBlogByFans(100000,1);
}
function initBlogNote(){
	$(".items").children(".blog_item").remove();
	getBlogByNote(100000,1);
}
function getPosition(){
	var url = "/HyperIT/position/findPosition";
	var parm = "";
	$.get(url,function(data){
		if (data.serviceResult) {
			var list = data.resultParm.positionlist;
			showPosition(list);
		} else{
			messageTip(data.resultInfo);
		}
	});
}
function showPosition(list){
	for(var i = 0; i<list.length; i++){
		$("#position ul").append('<li><a href="javascript:void(0)" onclick="getBlogByPosition(this,1000000,1,'+list[i].id+')">'+list[i].name+'</a></li>')
	}
}
